package com.example.controller;
import com.example.common.Result;
import com.example.common.ResultUtils;
import com.example.common.ThreadPoolManager;
import com.example.dto.ThreadPoolChange;
import com.example.dto.ThreadPoolInfo;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
@description:线程池管理器 提供线程池状态查询和动态调整接口
@ClassName ThreadPoolManagerController
@author chen
@create 2025-07-04 14:33
@Version 1.0
*/
@RestController
@RequestMapping("/threadPoolManager")
public class ThreadPoolManagerController
{
    /*
     * @==============History===============<br/>;
     * @Description //   获取所以的线程池信息
     * @Date 2025/7/8
     */
    @GetMapping("/threadPoolInfoList")
    public Result<List<ThreadPoolInfo>> threadPoolInfoList()
    {

        return ResultUtils.ok(ThreadPoolManager.threadPoolInfoList());
    }


    /*
     * @param threadPoolChange
     * @==============History===============<br/>;
     * @Description //   动态调整线程池参数
     * @Date 2025/7/8
     */
    @PostMapping("/threadPoolChange")
    public Result<Boolean> threadPoolChange(@RequestBody ThreadPoolChange threadPoolChange)
    {
        ThreadPoolManager.changeThreadPool(threadPoolChange);
        return ResultUtils.ok(true);
    }
}
